$(document).ready(function() { 
	var $em_txt = 'Please enter your email';
	var $time=0;//sec
	var $questions=["Where was Kailash Kher born?","What is the name of Kailash Kher's band?","What is the name of Kailash Kher & Kailasa's first album released in 2006?", "Which of these was Kailash Kher's first recording?", "How many albums have Kailasa released till now?", "Which song was Kailash Kher's first Bollywood song?"];
	var $ans = new Array();
	$ans[0]=["Barabanki","Lucknow","Meerut", "New Delhi"];
	$ans[1]=["Allah ke Bande","Rangile","Jhoomroo", "Kailasa"];
	$ans[2]=["Kailasa","Teri Deewani","Jhoomo Re", "Rangeele"];
	//$ans[3]=["Background song","Ad Jingle","Music Album", "Studio Album"];
	$ans[3]=["2","3","4", "5"];
	$ans[4]=["Andaz","Corporate","Waisa Bhi Hota Hai Part II", "Mangal Pandey: The Rising"];
	var $que_num = 1;
	var $answers = new Array();
	
	//Timer for Chanllenge page
	function timer() {
		$time++;
		$time = $time < 0 ? 0 : $time;

		var $minutes = Math.floor($time / 60);
		var $seconds = $time % 60;

		//$minutes = $minutes < 9 ? "0"+$minutes : $minutes;
		$seconds = $seconds < 9 ? "0"+$seconds : $seconds;
        $('.timer').html($minutes+":"+$seconds);
	}	
	 var $timer = setInterval(timer,1000);
	//Timer for Chanllenge page ends
	
	
	 $('.emailids').val($em_txt);
    /*change emai value*/	
    $('.emailids').blur(function(){
    	if (this.value=='') this.value=$em_txt;
    });
    
    $('.emailids').focus(function(){
    	if (this.value==$em_txt) this.value='';
    });
    /*change emai value ends*/
    
    $('.chell_ans').click(function(){
		$('.chell_ans').removeClass('active');
		$(this).addClass('active');
	});
    
  //Slider for homepageful screen
    $('.slider').anythingSlider({
        mode : "fade",
        buildArrows : false,
        buildStartStop : false,
        resizeContents : false,
        autoPlay : true,
        appendControlsTo : "#controller",
        delay : 7000,
		pauseOnHover        : false, 
        hashTags : false
    });
    
    
    /*** Questionaire */
    $('.chell_next_button').live('click', function(){
    	$sel_id =  $('.chell_from li.active').attr('id') ;
    	
    	if($sel_id=='undefined' || $sel_id == undefined){
    			alert('Please select answer.');
    	}else{
    		    		
    		$answers[$que_num] = $sel_id;
    		$('.chell_kailash').html( $questions[$que_num] );
    		$('#chell_a').text( ""+ $ans[$que_num][0] +"");
    		$('#chell_b').text( $ans[$que_num][1] );
    		$('#chell_c').text( $ans[$que_num][2] );
    		$('#chell_d').text( $ans[$que_num][3] );
    		$('.chell_ans').removeClass('active');
    		if($que_num >=5){
    			$('.chell_next_button').addClass('chell_submit_button');
    			$('.chell_submit_button').removeClass('chell_next_button');
    			$que_num = 6;
    		}else{
    			$que_num++;  
    		}
    		  		
    		$('.chell_question_text_2 span').text($que_num);
    	}
    	
    });
    
    $('.chell_submit_button').live('click', function(){
    	$sel_id =  $('.chell_from li.active').attr('id') ;
    	
    	if($sel_id=='undefined' || $sel_id == undefined){
    			alert('Please select answer.');
    	}else{
    		console.log($answers);
    		clearInterval($timer);
    	}
    });
    
    /**** End Questionaire */
    
    $('.subscriber_email_submit').click(function(){
    	if( $('.emailids').val() =='' || $('.emailids').val() == $em_txt ){
    		alert('Please enter a valid email id.');
    	}else{
    		$.ajax({
	    		url: "test.html"
    		}).done(function() {
    			alert('You have successfully prebooked your seat.');
    		});
    	}
    });
    
});
